﻿
$(document).ready(function () {
	lines.Initialize();
	lines.registerHelpers();
	lines.startSignalR();
});

var lines = {
	Initialize: function () {
		$(document).on("mouseover", ".lines-odd", function () {
			$(this).addClass("lines-odd-over");
		});
		$(document).on("mouseout", ".lines-odd", function () {
			$(this).removeClass("lines-odd-over");
		});
	},
	startSignalR: function () {
		$.ajax({ url: "Templates/Lines" }).done(function (result) {
			var template = Handlebars.compile(result);
			var linesHub = $.connection.linesHub;
			linesHub.client.sendLines = function (lines) {
				//alert(JSON.stringify(lines));
				var data = { lines: lines };
				$('#soccer\\/live\\/la-liga').html(template(data));
			};
			$.connection.hub.start();
		});
		
	},
	registerHelpers: function () {
		Handlebars.registerHelper("formatPrice", function (price) {
			if (price > 0) {
				return '+' + price.toString();
			}
			return price;
		});
	}
};


